<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.Statement" %>
<%@ page import="java.sql.DriverManager" %><%--
  Created by IntelliJ IDEA.
  User: lenovo
  Date: 2018/4/3
  Time: 0:53
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>用户更新</title>
</head>
<body>
<p><a href="index.jsp">返回列表</a></p><br/>
<form method="post" action="">
    <input type="text" name="id" value="${param.id}" hidden></br>
    用户：<input type="text" name="username" value="${param.username}"></br>
    密码：<input type="text" name="password" value="${param.password}"></br>
    <input type="submit" id="input" value="更新">
</form>
<%
    request.setCharacterEncoding("UTF-8");
    String id=request.getParameter("id");
    String name= request.getParameter("username");
    String password=request.getParameter("password");
    Connection connection=null;
    Statement statement=null;
    Class.forName("com.mysql.jdbc.Driver");
    connection= DriverManager.getConnection("jdbc:mysql://localhost:3306/sctu_javaweb_2018?serverTimezone=UTC",
            "root",
            "123456");
    statement=connection.createStatement();
    statement.executeUpdate("UPDATE t_users SET username='"+name+"',password='"+password+"' WHERE id='"+id+"'");
    connection.close();
    statement.close();
%>
</body>
</html>
